/**
 *
 * 选择日期 区间
 *
 * */
import {ICellInputProps} from "@/biz-components/claim-items/components-v2/cell-input/ICellInputProps";
import {DatePicker} from "antd";
import moment from "moment";

export interface SelectDateRangeExtraProps {

}

/**
 * value 是字符串 ‘YYYY-MM-DD’ 数组 或者空字符串数组
 * */
export function SelectDateRange(props: SelectDateRangeExtraProps & ICellInputProps<string[]>) {
	let {value, onChange} = props;

	if(!value) {
		// @ts-ignore
		value = [null, null]
	} else {
		// @ts-ignore
		value = value.map((item) => item ? moment(item): null)
	}

	return (
		<DatePicker.RangePicker
			allowClear
			// @ts-ignore
			value={value}
			onChange={(v, dateString) => {
				onChange(dateString)
			}}
			disabled={props.disabled}
		/>
	)
}
SelectDateRange.defaultValue = ['', ''];